{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "66d13328",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "money:2\n",
      "商品清单：a1饼干5元；b1火腿肠2元；c1面包5元；d1方便面10元；e1薯片10元；f1瓜子8元\n",
      "number:a1\n",
      "您的账户余额不足！\n",
      "请输入任意字母退出:z\n",
      "购买失败,余额为2元！\n"
     ]
    }
   ],
   "source": [
    "# 商品编号为a,b,c,d,e,f,g,h,i......\n",
    "a = \"5\" \n",
    "b = \"2\"\n",
    "c = \"5\"\n",
    "d = \"10\"\n",
    "e = \"10\"\n",
    "f = \"8\"\n",
    "a1 = int(a) \n",
    "b1 = int(b) \n",
    "c1 = int(c) \n",
    "d1 = int(d) \n",
    "e1 = int(e) \n",
    "f1 = int(f) \n",
    "A1 = \"饼干\"\n",
    "money = input(\"money:\")\n",
    "print(\"商品清单：a1饼干5元；b1火腿肠2元；c1面包5元；d1方便面10元；e1薯片10元；f1瓜子8元\")\n",
    "number = input(\"number:\")\n",
    "number1 = eval(number)\n",
    "money1 = int(money)\n",
    "minus = float(money1) - (number1)\n",
    "if number1 <= money1:\n",
    "    print(\"购买成功！\")\n",
    "    ww = input('请输入任意字母退出:')\n",
    "    print(\"您已成功购买\"+str(number)+\",\"\"余额为\"+str(minus)+\"元！\")\n",
    "    \n",
    "else:\n",
    "        print(\"您的账户余额不足！\")\n",
    "        ww = input('请输入任意字母退出:')\n",
    "        print(\"购买失败\"+\",\"\"余额为\"+str(money1)+\"元！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c79f2816",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "money:10\n",
      "商品清单：a1饼干5元；b1火腿肠2元；c1面包5元；d1方便面10元；e1薯片10元；f1瓜子8元\n",
      "number:a1\n",
      "购买成功！\n",
      "请输入任意字母退出:s\n",
      "您已成功购买a1,余额为5.0元！\n"
     ]
    }
   ],
   "source": [
    "# 商品编号为a,b,c,d,e,f,g,h,i......\n",
    "a = \"5\" \n",
    "b = \"2\"\n",
    "c = \"5\"\n",
    "d = \"10\"\n",
    "e = \"10\"\n",
    "f = \"8\"\n",
    "a1 = int(a) \n",
    "b1 = int(b) \n",
    "c1 = int(c) \n",
    "d1 = int(d) \n",
    "e1 = int(e) \n",
    "f1 = int(f) \n",
    "A1 = \"饼干\"\n",
    "money = input(\"money:\")\n",
    "print(\"商品清单：a1饼干5元；b1火腿肠2元；c1面包5元；d1方便面10元；e1薯片10元；f1瓜子8元\")\n",
    "number = input(\"number:\")\n",
    "number1 = eval(number)\n",
    "money1 = int(money)\n",
    "minus = float(money1) - (number1)\n",
    "if number1 <= money1:\n",
    "    print(\"购买成功！\")\n",
    "    ww = input('请输入任意字母退出:')\n",
    "    print(\"您已成功购买\"+str(number)+\",\"\"余额为\"+str(minus)+\"元！\")\n",
    "    \n",
    "else:\n",
    "        print(\"您的账户余额不足！\")\n",
    "        ww = input('请输入任意字母退出:')\n",
    "        print(\"购买失败\"+\",\"\"余额为\"+str(money1)+\"元！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13559552",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
